package com.java46.controller;

import com.java46.bean.Bespeak;
import com.java46.bean.JsonBean;
import com.java46.bean.Product;
import com.java46.exception.MyException;
import com.java46.service.BespeakService;
import com.java46.util.ControllerUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@CrossOrigin(origins = "*", maxAge = 3600)
public class BespeakController {
    @Autowired
    private BespeakService bespeakService;

    @RequestMapping("queryBespeaks")
    @ResponseBody
    public JsonBean queryBespeaks(){
        List<Bespeak> bespeaks;

        try {
            bespeaks = bespeakService.queryBespeaks();
        } catch (MyException e) {
            e.printStackTrace();
            return ControllerUtil.setFail(e.getErrorMsg());
        }
        return ControllerUtil.setSuccess(bespeaks);
    }


}

